from selenium import webdriver
from time import sleep
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium import webdriver
# 导入 Service 类（关键）
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.select import Select
#实例化对象：

service = Service(executable_path="E:\\python\\python38\\chromedriver.exe")
driver = webdriver.Chrome(service=service)
driver.get("http://121.43.169.97:8848/pageA.html")
action = ActionChains(driver)

# #先选择广州
# el=driver.find_element(By.CSS_SELECTOR,"#selectA")
# select=Select(el)
# sleep(2)
# select.select_by_index(2)
# #暂停两秒选择上海
# sleep(2)
# select.select_by_index(1)
# #暂停两秒选择北京
# sleep(2)
# select.select_by_index(0)
#-----------value选择
#先选择广州
# el=driver.find_element(By.CSS_SELECTOR,"#selectA")
# select=Select(el)
# sleep(2)
# select.select_by_value("gz")
# #暂停两秒选择上海
# sleep(2)
# select.select_by_value("sh")
# #暂停两秒选择北京
# sleep(2)
# select.select_by_value("bj")
#-------------text选择器
el=driver.find_element(By.CSS_SELECTOR,"#selectA")
select=Select(el)
sleep(2)
select.select_by_visible_text("广州")
sleep(2)
select.select_by_visible_text("上海")
sleep(2)
select.select_by_visible_text("北京")